<?php
set_time_limit(0);
header("Content-type:text/html;charset=utf-8");
include_once dirname(dirname(__FILE__))  . "/v2/common.php";
\ns_core\m_load::load("ns_core.m_config");
\ns_core\m_load::load("ns_model.message.message_queue");
include_once dirname(dirname(__FILE__)) . '/nn_logic/nl_common.func.php';
include_once dirname(dirname(__FILE__)) . '/nn_logic/message/nl_message.class.php';
define('XIAOLE_MOIVE_IMPORT_CP', 'JSCN');
$dc = nl_get_dc(array(
    'db_policy' => NL_DB_WRITE,
    'cache_policy' => NP_KV_CACHE_TYPE_MEMCACHE
));

$sql="select * from nns_mgtvbk_message where nns_cp_id not like 'fuse_%' and nns_cp_id !='JSCN'  and nns_message_xml !=''  and nns_message_xml is not null order by nns_modify_time asc limit 1000";
$result = nl_query_by_db($sql, $dc->db());
if(!is_array($result))
{
    die('Ok');
}
$time = date("Y-m-d H:i:s");
foreach ($result as $message_info)
{
    var_dump($message_info['nns_message_id']);
    if(isset($message_info['nns_message_xml']) && strlen($message_info['nns_message_xml'])>0 && preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$message_info['nns_message_xml']))
    {
        $result_curl = m_public::get_curl_content($message_info['nns_message_xml']);
        if(isset($result_curl['data_info']) && strlen($result_curl['data_info']) > 0 && m_public::is_xml($result_curl['data_info']))
        {
            $message_info_v2= array(
                'nns_message_content'=>$result_curl['data_info'],
                'nns_modify_time'=>$time,
            );
            nl_message::update_message($dc,array('nns_id'=>$message_info['nns_id']),$message_info_v2);
        }
    }
}